﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TemplateWeb.Models.ViewModels.GroupViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
		<% if (ViewData["OrderResult"] != null && ViewData["OrderResult"].ToString() != ""){ %>
			alert('<%= ViewData["OrderResult"].ToString() %>');
		<% } %>

        <% if (ViewData["XacNhanHuyMsg"] != null && ViewData["XacNhanHuyMsg"].ToString() != ""){ %>
			alert('<%= ViewData["XacNhanHuyMsg"].ToString() %>');
		<% } %>
	</script>
<div class="content_panel">
    <div class="box_center">
	    <div class="title"><span>Lịch sử giao dịch</span><div class="bg"><img src="../../Content/Images/Home/bg_title_right.png"></div></div>
	    <div class="content">
            <div id="content">
                <div id="container">
                    <div id="div_float">
                        <div id="div_cart">
                            <br />
                            <table border="0" width="100%" cellspacing="0" cellpadding="0" style="background:#fff; font-size:11px; border: 1px #DBDBDB solid;">
                                <thead style="background-color: #F3F3F3; color: #FF0000; font-size: 12px;">
                                    <tr>
                                        <th>ID</th>
                                        <th>Ngày đặt hàng</th>
			                            <th>Đã xác nhận</th>
			                            <th>Đã giao hàng</th>
                                        <th>Hủy đơn hàng</th>
			                            <th></th>
                                    </tr>
                                </thead>
                                <tbody style="font-size: 12px;">
                                <% for (int i = 0; i < Model.DonDatHangModel.GetModel.LstObjModel.Count; i++)
                                    { %>
                                    <tr style="height: 20px"> 
                                        <td style="text-align: center;"><span style=""><%= Model.DonDatHangModel.GetModel.LstObjModel[i].ID %></span></td>
			                            <td style="text-align: center"><span style=""><%= string.Format("{0:dd/MM/yyyy hh:mm:ss}", Model.DonDatHangModel.GetModel.LstObjModel[i].NgayDatHang.Value)%></span></td>
			                            <td style="text-align: center; vertical-align: middle"><span style=""><%= Html.CheckBox("IsVerified", Model.DonDatHangModel.GetModel.LstObjModel[i].DaXacNhan.Value, new { disabled = "disabled" })%></span></td>
			                            <td style="text-align: center; vertical-align: middle"><span style=""><%= Html.CheckBox("IsShipped", Model.DonDatHangModel.GetModel.LstObjModel[i].DaGiaoHang.Value, new { disabled = "disabled" })%></span></td>
                                         <td style="text-align: center; vertical-align: middle"><span style=""><%= Html.CheckBox("IsShipped", Model.DonDatHangModel.GetModel.LstObjModel[i].HuyDonHang.Value, new { disabled = "disabled" })%></span></td>
			                            <td style="text-align: center">
                                            <a href="../../Home/SelectOrderDetailByIDOrder?iduser=<%= Model.UsersModel.GetModel.LstObjModel[0].BaseInfo.ID %>&idorder=<%= Model.DonDatHangModel.GetModel.LstObjModel[i].ID %>">
					                            <span style="">Select</span>
				                            </a>
			                            </td>
                                    </tr>
                                <% } %>
                                </tbody>
                            </table>
                            <% if (Model.SelectedDonDatHangModel != null)
                               { %>
                               <%
                                   var total = 0.0;
                                   for (int i = 0; i < Model.ChiTietDonDatHangModel.GetModel.LstObjModel.Count; i++)
                                   {
                                       total += (Model.ChiTietDonDatHangModel.GetModel.LstObjModel[i].SoLuong.Value * Model.ChiTietDonDatHangModel.GetModel.LstObjModel[i].Gia.Value);
                                   }
                                %>
                                <div style="text-align:left;">
                                <br /><br />
                                <span style="font-size:18px; font-weight:bold;">Mã đơn đặt hàng <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].ID %></span>
                                <br />
                                <br />
                                <table class="AdminPageText">
                                  <tr>
                                    <td width="130" style="font-weight: bold;">Tổng tiền:</td>
                                    <td style="font-weight: bold; color: Red">
                                        <%= string.Format("{0:0,0}", total)%> Đ
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Mã Khách hàng:</td>
                                    <td>
                                        <%= Model.UsersModel.GetModel.LstObjModel[0].BaseInfo.ID %>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Tên khách hàng:</td>
                                    <td>
                                        <%= Model.UsersModel.GetModel.LstObjModel[0].ExtraInfo.HoTen %>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Tên người nhận:</td>
                                    <td>
                                        <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].TenNguoiNhan %>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">SĐT người nhận:</td>
                                    <td>
                                        <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].SoDienThoaiNguoiNhan %>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Địa chỉ người nhận:</td>
                                    <td>
                                        <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].DiaChiNguoiNhan %>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Ngày đặt hàng:</td>
                                    <td>
                                        <%= string.Format("{0:dd/MM/yyyy hh:mm:ss}", Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].NgayDatHang.Value)%>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Đã xác nhận:</td>
                                    <td>
                                        <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].DaXacNhan.Value ? "Rồi" : "Chưa" %>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Đã giao hàng:</td>
                                    <td>
                                        <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].DaGiaoHang.Value ? "Rồi" : "Chưa"%>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Ngày giao hàng:</td>
                                    <td>
                                        <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].NgayGiaoHang != null ? string.Format("{0:dd/MM/yyyy hh:mm:ss}", Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].NgayGiaoHang.Value) : string.Empty%>
                                    </td>
                                  </tr>
                                  <tr>
                                    <td width="130">Chú thích thêm:</td>
                                    <td>
                                        <%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].ChuThich %>
                                    </td>
                                  </tr>
                                </table>
                                <br />
                                <div style="height: 20px;">
                                <span style="font-weight: bold;">Chi tiết đơn đặt hàng</span>
                                </div>
                                <table border="0" width="100%" cellspacing="0" cellpadding="0" style="background:#fff; font-size:11px; border: 1px #DBDBDB solid;">
	                                <thead style="background-color: #F3F3F3; color: #FF0000; font-size: 12px;">
		                                <tr>
			                                <th style="text-align: center;">STT</th>
                                            <th style="text-align: left; padding-left: 10px;">Tên sách</th>
                                            <th style="text-align: center;">Số lượng</th>
			                                <th style="text-align: center;">Đơn giá</th>
		                                </tr>
	                                </thead>
                                    <tbody style="font-size: 12px;">
	                            <% for (int i=0; i<Model.ChiTietDonDatHangModel.GetModel.LstObjModel.Count; i++){
		                            if (i % 2 != 0) {%>
		                            <tr class="Row" id="Tr1" style="height: 20px">
		                            <% }
		                            else { %>
		                            <tr class="AlternatingRow" id="row-<%= Model.ChiTietDonDatHangModel.GetModel.LstObjModel[i].ID %>" style="height: 20px">
		                            <% } %>
                                        <td style="text-align: center"><span style=""><%= (i + 1) %></span></td>
                                        <td style="text-align: left; padding-left: 10px;"><span style=""><%= Model.ChiTietDonDatHangModel.GetModel.LstObjModel[i].Sach.TenSach %></span></td>
			                            <td style="text-align: center"><span style=""><%= Model.ChiTietDonDatHangModel.GetModel.LstObjModel[i].SoLuong.Value %></span></td>
			                            <td style="text-align: center"><span style=""><%= string.Format("{0:0,0}", Model.ChiTietDonDatHangModel.GetModel.LstObjModel[i].Gia.Value) %> Đ</span></td>
		                            </tr>
	                            <% } %>  
                                </tbody>
                            </table>
                            </div>
                            <div style="text-align: right; padding:10px; margin: 5px;">
                                <script type="text/javascript">
                                    function ValidateUpdateRevenue() {
                                        var dagiaohang = '<%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].DaGiaoHang.Value %>';
                                        if (dagiaohang) {
                                            alert("Khi đã giao hàng thì không được hủy đơn hàng");
                                            return false;
                                        }
                                        return true;
                                    }
                                </script>
                                <% using (Html.BeginForm("UserCancelOrder", "Home", FormMethod.Post, new { id = "MySubmitForm", onsubmit = "return ValidateUpdateRevenue();" }))
                                   { %>
                                    <input type="hidden" name="Orders_IDUser" value="<%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].NguoiDung.ID%>" />
                                    <input type="hidden" name="Orders_ID" value="<%= Model.SelectedDonDatHangModel.GetModel.LstObjModel[0].ID%>" />
                                    <input type="submit" name="sbt" id="Submit1" value="Hủy đơn hàng" style="background-image: url(../../../Content/Images/Home/bgbutton.jpg); color: #FFFFFF; font-size: 16px; font-weight: bold; border: 1px #DBDBDB solid; height: 30px; cursor:pointer;" />
                                <% } %>
                            </div>
                            <% } %>
                        </div>
                    </div>
                </div>
            </div>
            <br />
        </div>
    </div>
</div>
</asp:Content>
